package com.lw.test;

public class IOC {

    public static void main(String[] args) {
        Car car = new Car();
        car.run();
    }

    static class Car {
        private Framework framework;
        public Car() {
            framework = new Framework();
            System.out.println("car init");
        }
        public void run() {
            System.out.println("car run run!");
        }
    }

    //车身
    static class Framework {
        private Bottom bottom;
        public Framework() {
            bottom = new Bottom();
            System.out.println("Framework init");
        }
    }

    //底盘
    static class Bottom {
        private Tire tire;
        public Bottom() {
            tire = new Tire(20);
            System.out.println("bottom init");
        }
    }

    //轮子
    static class Tire {
        //轮子尺寸
        private int size;

        public int getSize() {
            return size;
        }

        public void setSize(int size) {
            this.size = size;
        }
        //轮子传参
        public Tire(int size) {
            this.size = size;
            System.out.println("tire init 有参数值:" + size);
        }

        public Tire() {
            this.size = 15;
            System.out.println("tire init 值:" + size);
        }
    }
}
